<div id="mainContent">
		<div class="content">
			<?php $logged = isset($params['user'])? true : false;?>
			<h3><img src="images/salle.png" alt=""/><?php echo $params['salle']->getNom(); ?> :
				<?php foreach($params['salle']->getTheme() as $theme) { ?>
				<a href="index.php?control=salle&action=viewfilter&args[]=<?php echo $theme->getIdTheme(); ?>">
				<span class="theme"><?php echo $theme->getNomTheme();?></span></a>
				<?php }?>
				<span class="auteur"> créée par <?php $auteur = $params['salle']->getAuthor(); echo $auteur['PSEUDO']; ?></span>
			</h3>
			
			<?php 
			$groupes = $params['salle']->getGroupes();
			if(empty($groupes) || ($logged && ($params['salle']->accesSalle($params['user']->getId())) || $params['user']->getStatusId()==0)) {
			
			$message = $params['salle']->getMessages();
			if(!empty($message)) {?>					
			<div id="messagesContener">
				<div class="message">
					<?php
					foreach($params['salle']->getMessages() as $message) {?>
				
					<div class="titre" id="<?php echo $message['message']->getMessageId(); ?>">
							<h3><?php echo $message['message']->getTitle(); ?><span class="postDetails"> par <?php $auteur = $message['message']->getAuthor(); echo $auteur['PSEUDO'];?>, le <?php echo $message['message']->getDatePost(); ?></span>
								<span class="nbLike">
									<span class="number"><?php echo $message['message']->getNombreLike();?></span>
									<?php if($logged && $message['message']->isLikedBy($params['user']->getId())) {
										?>	<span class="like" id="<?php $message['message']->getMessageId(); ?>">&nbsp;</span>
									<?php } else {?>
											<span class="unlike" id="<?php $message['message']->getMessageId(); ?>">&nbsp;</span>
									<?php } ?>
								</span>
							</h3>
					</div>
					
					<p>
						<?php echo $message['message']->getContenu(); ?>	
					</p>
					
					<div class="comments">
						<?php if(!empty($message['comments'])) {
								foreach($message['comments'] as $comment) {?>
						<div class="message">
							<div class="titre" id="<?php echo $comment->getMessageId(); ?>">
								<h3><?php echo $comment->getTitle();?><span class="postDetails"> par <?php $auteur = $comment->getAuthor(); echo $auteur['PSEUDO']; ?>, le <?php echo $comment->getDatePost(); ?></span>
								<span class="nbLike">
									<span class="number"><?php echo $comment->getNombreLike();?></span>
									<?php if($logged && $comment->isLikedBy($params['user']->getId())) {
											?>	<span class="like">&nbsp;</span>
										<?php } else {?>
												<span class="unlike">&nbsp;</span>
										<?php } ?>
								</span>
								</h3>
							</div>
							<p>
								<?php echo $comment->getContenu(); ?>
							</p>
						</div>
						
						<?php }?>
						<div class="inputForm">
							<form method="post" action="#">
								<input type="text" name="COMMENT" placeholder="Ajouter un commentaire" required/>
								<input type="hidden" name="TITRE" value="<?php echo $message['message']->getTitle(); ?>"/>
								<input type="hidden" name="PARENT" value="<?php echo $message['message']->getMessageId(); ?>"/>
								<input type="submit" name="COMMENTPOST" value="Ajouter" <?php if(!$logged) echo 'disabled';?>/>
							</form>
						</div>	
						<?php } else { ?>
						 	<div class="add_comment">
					 			<h5><span class="arrow_comment"></span> Ajouter un commentaire</h5>
							 	<div class="inputForm2">
							 		<form method="post" action="#">
										<input type="text" name="COMMENT" placeholder="Ajouter un commentaire" required/>
										<input type="hidden" name="PARENT" value="<?php echo $message['message']->getMessageId(); ?>"/>
										<input type="submit" name="COMMENTPOST" value="Ajouter" <?php if(!$logged) echo 'disabled';?>/>
									</form>
								</div>	
							</div>
						 <?php }
					} ?>
					
					</div>
				</div>
				<?php } else 
				{
					echo "Aucun post dans cette salle pour l'instant";
				}?>
				<div id="postMessage">
					<form method="post" action="#">
						<input type="text" name="TITRE" placeholder="Entrez votre titre" required/>					
						<textarea name="MESSAGE" placeholder="Entrez votre texte" required></textarea><br/>
						<!--<input type="text" name="postInput" placeholder="Entrez du texte"/>-->
						<input type="submit" name="POSTMESSAGE" value="Poster" <?php if(!$logged) echo 'disabled';?>/>
					</form>
				</div>
				<?php } else { echo "<p>Vous n'avez pas accès à cette salle.</p>"; }?>
		</div>
	</div>
</div>